package edu.rjxy.xjdx.emps.servlet;

import edu.rjxy.xjdx.emps.common.domain.Employee;
import edu.rjxy.xjdx.emps.service.EmployeeService;
import edu.rjxy.xjdx.emps.service.EmployeeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/showEmp4Edit")
public class ShowEmpEditServlet extends HttpServlet {
    EmployeeService employeeService = new EmployeeServiceImpl();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String idTxt = request.getParameter("id").trim();
        int id = Integer.parseInt(idTxt);
       Employee employee =  employeeService.findEmployeeById(id);
       request.setAttribute("emp",employee);
        request.getRequestDispatcher("/pages/layer_empEdit.jsp").forward(request,response);
    }
}
